<?php 
include 'include/functions.php';

$page = $_POST["page"];

if ($page == '' or $page == null) {
	$page = $_GET["page"];
}

if($page=="") $page=1;

$result = getMustDo($page);
$arrMustDo = $result["MustDo"];
$lastPage = $result["lastPage"];

$arrMustDo = array_map(function($r) {
	$r['description'] = utf8_encode($r['description']);
	$r['picture'] = utf8_encode($r['picture']);
	$r['datetime'] = utf8_encode(convertDate($r['datetime'], "dd/mm/yyyy", "yyyy-mm-dd hh:mm:ss"));
	return $r;
}, $arrMustDo);

$data = array('MustDo' => $arrMustDo, 'status' => "ok", 'message' => "showing Page: $page", 'lastPage' => $lastPage);

$json = json_encode($data);

echo $json;
?>